<template>
  
  <view class="errormsgDiv" v-if="nodata">
    <view class="errormsg">\（￣︶￣）/</view>
    <view class="errormsg2">没有相关数据</view>
  </view>

  <view v-else class="cu-list menu sm-border" style="margin-top: 0;">

		<navigator  class="cu-item arrow"  :key="index"  v-for="(item,index) in listData1" :url="'/pages/bills/cars_bill?parking_id='+item.parking_id+'&number_plate='+item.number_plate+'&community_id='+item.community_id">
			<view class="cu-avatar" style="background-color:#FFFFFF;" :style="'background-image:url(/static/11.png);'"></view>
			<view class="content">
				<view class="text-grey">
					<view class="text-cut padding-lr"> 车位:{{item.parking_id}}</view>
				</view>
				<view class="text-gray text-sm flex">
					<view class="text-cut padding-lr"> 
						车牌:{{item.number_plate?item.number_plate:'无'}}
					</view>
				</view>
			</view>
			<view class="action">
				 
				 
			</view>
		</navigator>
 </view>
</template>

<script>
	import beeApp from '../../beeApp.js'
	export default {
		data() {
			return {
				userInfo:{},
				listData1: [],
				nodata:0,
			}
		},
		onLoad() {

		beeApp.getUserInfo((userInfo)=>{
			 this.getUserInfo();
		  })
		 
		},
		onShareAppMessage(res) {
		    if (res.from === 'button') {// 来自页面内分享按钮
		      console.log(res.target)
		    }
		  },
		
		onPullDownRefresh() {
			this.load();
			uni.stopPullDownRefresh();
		},
		methods: {
			load: function() {
				this.getMyCars();
			},
			 getUserInfo:function(){
                    var that = this;
                    beeApp.api("/api/user/info",{
                        fields:"user_id,store_id,phone,nickname,phone,avatarUrl,last_update_time"
                    },function(res){
                         if(res.code==200){
                             that.userInfo = res.data;
                         }
						 that.getMyCars();
                        
                    });
            },
			getMyCars() {
				var that = this;
				beeApp.api("api/community_cars/get", {
					page: 1,
					phone: this.userInfo.phone,
					limit: 20,
				}, function(res) {
					if (res.code != 200) {
						beeApp.alert(res.msg);
						return;
					}
					if(res.data.list.length==0){
						that.nodata=1;
					}else{
						that.nodata=0;
					}
					that.listData1 = res.data.list
				})
			},
	  }
	}
</script>

<style>
</style>
